<template>
    <div class="address">
        <ul>
            <li v-for="item in list" :key="item.id" >
                <div @click="goOrder(item)">
                    名称:{{ item.name }}
                    <br>
                    {{ item.address }}
                    <hr>
                </div>
                <div @click="goEdit(item.id)">
                    编辑
                </div>
            </li>
        </ul>
        <button @click="add">
            新增地址
        </button>
    </div>
</template>

<script>
import {
    getListAction
} from "@/api/cart/order/address"
export default {
    data() {
        return {
            list:[]
        };
    },
    computed: {

    },
    created() {
        getListAction({ // mixins
            openId:localStorage.getItem("openId")
        })
        .then(res =>{
            console.log(res)
            this.list = res.data
        })
    },
    mounted() {

    },
    methods: {
        add(){
            this.$router.push("/cart/order/address/addAddress")
        },
        goEdit(id){
            this.$router.push(`/cart/order/address/edit/${id}`)
        },
        goOrder(address){
            // this.$router.push("/cart/order")
            localStorage.setItem("addressInfo",JSON.stringify(address))
            this.$router.go(-1)
        }
    },
};
</script>

<style scoped lang="scss">
.address{
    li{
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
}
</style>
